//
//  DataCollectionViewCell.m
//  YouinRTCDemo
//
//  Created by 潘欣 on 2025/6/4.
//

#import "DataCollectionViewCell.h"
@interface DataCollectionViewCell ()
@property (nonatomic,strong)UILabel *label;
@property (nonatomic,strong)UILabel *value;
@property (nonatomic,strong)NSArray *labelsArray;
@property (nonatomic,strong)NSArray *labels2Array;
@property (nonatomic,strong)NSArray *labels3Array;
@property (nonatomic,strong)NSArray *labels4Array;
@end

@implementation DataCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.cornerRadius = 2;
        self.clipsToBounds = YES;
        self.labelsArray = [NSArray arrayWithObjects:@"总访问人次",@"总访问人数",@"总观看人数",@"观看转化率",@"人均观看时长",@"最高在线", nil];
        self.labels2Array = [NSArray arrayWithObjects:@"分享次数",@"邀请人数",@"有效邀请人数",@"本场拉新", nil];
        self.labels3Array = [NSArray arrayWithObjects:@"点赞次数",@"礼物收益(元)",@"红包总额(元)", nil];
        self.labels4Array = [NSArray arrayWithObjects:@"购买人数",@"商品点击人数",@"商品点击次数",@"订单数",@"累计订单金额(元)",@"成功退款金额(元)" ,nil];
        
        self.value = [[UILabel alloc] init];
        self.value.textColor =RYColorForHex(@"#333333");
        self.value.font = [UIFont systemFontOfSize:14];
        [self addSubview:self.value];
        
        [self.value mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.mas_equalTo(self).offset(8);
        }];
        
        
        self.label = [[UILabel alloc] init];
        self.label.textColor =RYColorForHex(@"#888888");
        self.label.font = [UIFont systemFontOfSize:12];
        [self addSubview:self.label];
        
        [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self).offset(8);
            make.top.mas_equalTo(self.value.mas_bottom).offset(5);
        }];        
    }
    return self;
}

- (void)dataSection:(NSInteger)section withIndex:(NSInteger)index withData:(NSMutableArray *)data
{
    if (section == 0) {
        if (index == 0) {
            self.backgroundColor = RYColorForHex(@"#EFF7FF");
        }else if (index == 3)
        {
            self.backgroundColor = RYColorForHex(@"#FFF7F0");
        }else{
            self.backgroundColor = RYColorForHex(@"#F9F9F9");
        }
    }else if (section == 1)
    {
        self.backgroundColor = RYColorForHex(@"#F9F9F9");
    }else if (section == 2)
    {
        if (index == 0) {
            self.backgroundColor = RYColorForHex(@"#F0F8FF");
        }else if (index == 1)
        {
            self.backgroundColor = RYColorForHex(@"#F3F0FF");
        }else{
            self.backgroundColor = RYColorForHex(@"#FFF0F0");
        }
    }else
    {
        if (index == 0) {
            self.backgroundColor = RYColorForHex(@"#F0F2FF");
        }else if (index == 3)
        {
            self.backgroundColor = RYColorForHex(@"#FFF0F0");
        }else{
            self.backgroundColor = RYColorForHex(@"#F9F9F9");
        }
    }
    
    if (data.count!=0) {
        if (section == 0) {
            self.label.text = self.labelsArray[index];
        }else if (section == 1)
        {
            self.label.text = self.labels2Array[index];
        }
        else if (section == 2)
        {
            self.label.text = self.labels3Array[index];
            
        }else if (section == 3)
        {
            self.label.text = self.labels4Array[index];
            
        }
        self.value.text = [NSString stringWithFormat:@"%@",data[section][index]];
    }
    
    
    
}


@end
